<?php
	require_once "header.php";
	session_start();
	$username="";
	$password="";
	
	if(isset($_POST['btn_login']) )
	{
		$filter = new CFilter;
		//cho nay con` thieu phan setFilter;	
		
		$username = $filter -> filter ($_POST['tf_username']);
		$password = $filter -> filter ($_POST['tf_password']);		
		$_SESSION['username']  = $username;
		$user = new CUsers;
		$isUser = $user->CUserIsUser($username,$password);
		
		if(is_array($isUser)== TRUE)
		{
			//echo $isUser['username'];
			/*echo '<script language="javascript">window.location.href="index.php?com=user&act=list"</script>';*/ 
			$_SESSION['username'] = $isUser['username'];
			$_SESSION['idUser'] = $isUser['id'];
			
			
			$_SESSION['lastLogin'] = mktime(date('h')+7,date('i'),date('s'),date('m'),date('d'),date('Y'));			
			echo '<script language="javascript">window.location.href="main.php"</script>';  	
		}
		else
		{
			echo '<script language="javascript">window.location.href="index.php"</script>';  	
		}		
	}
	else
	{
		echo '<script language="javascript">window.location.href="index.php"</script>';  	
	}	
	



?>